<template>
  <div id="course_detail">
    <header1></header1>

    <div class="container layout layout-margin-top">
      <div class="row">
        <div class="col-md-6 layout-body">
          <video :src="videoSrc" controls ></video>

        </div>
        <div class="col-md-6 layout-side">
          <ssh></ssh>
          <h3 class="text-center">实验报告</h3>
           <div class="text-center" style="padding:5px 0"><input  class="text-center" type="text" v-model="report_title" placeholder="请输入报告标题"></div>
          <editer v-on:listentochildevents='showMesfromchild'></editer>
        </div>
      </div>
    </div>
    <footer1></footer1>
  </div>
</template>

<script>
import header from "./header";
import footer from "./footer"; 
import editer from "./editer";  

// import videojs from 'video.js'
// import 'videojs-contrib-hls'
import ssh from "./ssh";
import { orderCourse } from "../api/api.js";
export default {
  name: "course_detail",
  components: {
    header1: header,
    footer1: footer,
    ssh: ssh,
    editer: editer,

  },
  data() {
    return {
      course: "",
      section_id:'',
      course_id:'',
      user_id: localStorage.getItem("user_id"),
      tag: "",
      teacher: "",
      course_num: 0,
      sections: [],
      isTrue: 0,
      videoSrc: "http://www.gentlener.com:8888/group1/M00/00/01/rB_pcV2kXDGAAzYFAAuIZbzkjzc34..mp4",
      isError:false,
      report_content:'',
      report_title:''

    };
  },
  mounted() {
    this.videoSrc = this.$route.query.video;  
    this.section_id = this.$route.query.section_id;  
    this.course_id = this.$route.query.course_id;  
    this.axios({
      url:
        "/api/usersectioncourse/" ,
      method: "post",
      data:{'uid':this.user_id,'sid':this.section_id,'cid':this.course_id}
    }).then(res => {
        
    });

  },
  methods: {
    showMesfromchild(data){
      this.report_content=data
      // console.log(data)
      this.axios({
        url:'/api/addReport/',
        method:'post',
        data:{
          user_id:this.user_id,
          course_id:this.course_id,
          section_id:this.section_id,
          report_content:this.report_content,
          report_title:this.report_title,
        }
      }).then(res=>{
        if(res.data.code==200){
          alert(res.data.message);
          this.$router.go(0)
        }else{
          alert('添加失败')
        }
      })
    },
  },
  // beforeDestroy() {
  //   const videoDom = this.$refs.videoRef; //不能用document 获取节点
  //   videojs(videoDom).dispose(); //销毁video实例，避免出现节点不存在 但是flash一直在执行,也避免重新进入页面video未重新声明
  // }
};
</script>


